﻿
using System;
using System.Collections.Generic;


namespace CrazyMan.TM.Interface.Domain
{
    /// <summary>
    /// Represents a poker table in a tournament.
    /// </summary>
    public class Table
    {
        private List<Seat> _seats;

        /// <summary>
        /// Creates a new table.
        /// </summary>
        public Table()
        {
            this._seats = new List<Seat>();
        }

        /// <summary>
        /// Creates a new table with the specified number of seats on the table.
        /// </summary>
        /// <param name="seatCount">The number of seats that are available on the table.</param>
        public Table(int seatCount) : this()
        {
            //ensure valid number
            ValidateSeatCount(seatCount);

            AddEmptySeats(seatCount);
        }

        /// <summary>
        /// Represents a list of seats at the table.
        /// </summary>
        public List<Seat> Seats
        {
            get { return this._seats; }
        }

        /// <summary>
        /// Adds the specifed number of empty seats to the table.
        /// </summary>
        /// <param name="seatCount">The number of empty seats to add to the table.</param>
        protected void AddEmptySeats(int seatCount)
        {
            for (int i = 0; i < seatCount; i++)
            {
                Seat newSeat = new Seat();
                this._seats.Add(newSeat);
            }
        }

        /// <summary>
        /// Vaidates that the specified number of seats is valid.
        /// </summary>
        /// <param name="seatCount">The specified number of seats.</param>
        protected void ValidateSeatCount(int seatCount)
        {
            if (seatCount < 0)
                throw new ArgumentOutOfRangeException("seatCount", "Seat can not be a negative number.");
        }
    }
}
